Repository navigation
fix(runtime): coordinate graceful API shutdown - #373
Merged
Merged
Conversation
Signed-off-by: VBTG <vuppubhanu18@gmail.com>
Collaborator
Author
|
@VarshithReddy2006 I have implemented the changes for this issue. Please review my changes and merge this PR if everything looks good. |
VarshithReddy2006
approved these changes
Nov 16, 2026
VarshithReddy2006
left a comment
Owner
There was a problem hiding this comment.
LGTM! Verified graceful shutdown coordinator draining BullMQ workers, notifying SSE clients, and closing Redis and MongoDB connections with passing CI.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #362
I added one API shutdown path for SIGTERM and SIGINT. It closes the HTTP listener, notifies connected SSE clients to reconnect after a randomized 2–5 second delay, and gives local BullMQ workers up to five seconds to finish active jobs. I kept the drain local so workers on other replicas can continue processing.
I added deadlines for each phase. The coordinator flushes pending runtime state and audit writes, then closes Redis and MongoDB. It continues cleanup after a phase fails and reports the failures on exit.
Validation
I ran 54 worker lifecycle tests, 10 SSE resilience tests, 19 frontend reconnect tests, and 13 integration tests. The integration tests covered an open HTTP/SSE stream and disposable MongoDB. Both backend and frontend typechecks passed.
I did not exercise the BullMQ drain against a live Redis instance. The API watchdog is 15 seconds. A host with a shorter termination grace period can interrupt cleanup.